/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.transl;

import alloy.ast.LeafId;
import alloy.bool.BooleanFormula;
import alloy.bool.PartialAssignment;

/**
 * Allocates Boolean variables to relations.
 * @see DefaultRelationAllocator
 */
public abstract class RelationAllocator {
    /** Return the translation of the given relation */
    abstract public ExprTransl getRelationTransl(LeafId relId_);

    /**
     * Return an {@link IntTransl} of the integer represented
     * by the specified atom of the Int signature.
     */
    abstract public IntTransl getIntAtomTransl(int atomIdx_);

    /** Return the width (in bits) of integers allocated to the Int atoms */
    abstract public int getIntWidth();
	

    /**
     * Return the {@link BoolVarAllocator} (object that gives out new Boolean variable numbers)
     * that is being used by this RelationAllocator to allocate Boolean variables to relations.
     */
    abstract public BoolVarAllocator getBoolVarAllocator();

    /**
     * Simplify all {@link alloy.bool.BooleanFormula}s in translations of relations,
     * using the given {@link PartialAssignment}.  We do this after {@linkplain alloy.symm symmetry-breaking}
     * was used to choose constant values for some of the Boolean variables allocated to relations,
     * without changing the satisfiability of the formula.
     */
    abstract public void simplify(PartialAssignment pa_);

    /**
     * Return a side condition to be conjoined to the final formula.  This is used e.g.
     * by {@link CompactRelationAllocator}: if you have a scalar set of scope 3 and represent it
     * with two Boolean variables, we need the constraint that the two Boolean variables represent
     * a binary number less than 3.
     */
    public BooleanFormula getSideConditions() { return BooleanFormula.TRUE(); }
}


